<template>
  <section
    class="container"
    id="page"
    ref="page"
    v-loading="loading"
    element-loading-text="跳转中..."
    element-loading-spinner="el-icon-loading"
  ></section>
</template>

<script>
import { mapState } from "vuex";
export default {
  // 组件名称
  name: "demo",
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  computed: {
    ...mapState(["Authorization"]),
  },
  data() {
    return {
      loading: true,
      timeout: null,
    };
  },
  created() {
    let { jobId } = this.$route.query;
    if (!jobId) {
      this.$message.error("职位id不能为空");
      this.timeout = setTimeout(() => {
        this.$router.push({ name: "home" });
      });
      return;
    }
    if (!this.Authorization) {
      this.$message.error("请先登陆");
      this.timeout = setTimeout(() => {
        this.$router.push({ name: "login", params: { id: jobId } });
      });
      return;
    }

    localStorage.setItem("shareJobId", jobId);
    this.timeout = setTimeout(() => {
      localStorage.setItem("currentJobId", jobId);
      this.$router.push({
        path: `/jobDetail/${jobId}`,
      });
    });
  },
  // 组件方法
  methods: {},
  destroyed() {
    this.timeout = null;
  },
};
</script>
<style lang="less" scoped>
.container {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgb(237, 242, 249);
}
</style>
